package com.wn.prod.dubbo;

import com.wn.bean.entity.User;
import com.wn.client.UserDubboClient;
import com.wn.prod.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author yellow Docter
 * @date 2022 -11-01
 * @desc
 */
@DubboService
@Slf4j
public class UserDubboClientImpl implements UserDubboClient {

    @Autowired
    private IUserService userService;

    @Override
    public User findUserById(Integer id) {
        User user = userService.getById(id);
        log.info("prod 查询的结果是:{}",user);
        return user;

    }

    @Override
    public String addUser(User user) {

        boolean save = userService.save(user);
        return save ?" add success " : "add failer";
    }

    @Override
    public String deleteUser(Integer id) {

        boolean save = userService.removeById(id);
        return save ?" delete success " : "delete failer";
    }
}
